

//定义全局变量idvalue
var idValue;
/*通过id获取值*/
function getIdValue(id){
	// 通过id取得值ֵ
  idValue = document.getElementById(id).value;
  return idValue;
}

function userNameChk(id){
	// 判断用户名的长度是否超过30位或少于6
  if(getIdValue(id).length !=0 &&(getIdValue(id).length>30||getIdValue(id).length<6)){
	  document.getElementById("emailSpan").innerHTML = "* 对不起，用户名输入不合法！！";
  }else if(getIdValue(id).length !=0){
	  document.getElementById("emailSpan").style.color="green";
	  document.getElementById("emailSpan").style.size="20px";
	  document.getElementById("emailSpan").innerHTML = "√";
  }else{
	  document.getElementById("emailSpan").innerHTML = "* 必填，请输入有效邮箱注册(6-30)";
  }
}

function pwChk(id){
	//alert(getIdValue(id).length < 6||getIdValue(id).length > 16 );
	 //判断密码输入是否合法
  if(getIdValue(id).length !=0 && (getIdValue(id).length < 6||getIdValue(id).length > 16)){
	  document.getElementById("passWdSpan").innerHTML = "* 对不起，密码输入不合法！！";
  }else if(getIdValue(id).length !=0){
	  document.getElementById("passWdSpan").style.color="green";
	  document.getElementById("passWdSpan").style.size="20px";
	  document.getElementById("passWdSpan").innerHTML = "√";
  }else{
	  document.getElementById("passWdSpan").innerHTML = "* 必填，由字母、数字或“_”组成，长度不少于6位，不多于16位(6-30)";
  }
}

function rPwChk(id,id1){
	 // 判断两次输入密码是否相同
  if(getIdValue(id).length !=0 && (getIdValue(id) != getIdValue(id1))){
	  document.getElementById("rPassWdSpan").innerHTML = "* 对不起，两次密码输入不相同！！";
  }else if(getIdValue(id).length !=0){
	  document.getElementById("rPassWdSpan").style.color="green";
	  document.getElementById("rPassWdSpan").style.size="20px";
	  document.getElementById("rPassWdSpan").innerHTML = "√";
  }else{
	  document.getElementById("rPassWdSpan").innerHTML = "* 必填，请再次输入密码";
  }
}

function nameCnChk(id){
	// 判断用户名的长度是否超过30位或少于6
  if(getIdValue(id).length !=0 &&(getIdValue(id).length>30)){
	  document.getElementById("nameCnSpan").innerHTML = "* 对不起，此项为必填项目！";
  }else if(getIdValue(id).length !=0){
	  document.getElementById("nameCnSpan").style.color="green";
	  document.getElementById("nameCnSpan").style.size="20px";
	  document.getElementById("nameCnSpan").innerHTML = "√";
  }else{
	  document.getElementById("nameCnSpan").innerHTML = "* 必填";
  }
}

function ageChk(id){
	// 判断用户名的长度是否超过30位或少于6
  if(getIdValue(id).length !=0 &&(getIdValue(id).length>30||getIdValue(id).length<6)){
	  document.getElementById("ageSpan").innerHTML = "* 对不起，此项为必填项目！";
  }else if(getIdValue(id).length !=0){
	  document.getElementById("ageSpan").style.color="green";
	  document.getElementById("ageSpan").style.size="20px";
	  document.getElementById("ageSpan").innerHTML = "√";
  }else{
	  document.getElementById("ageSpan").innerHTML = "* 必填";
  }
}

//页面初始化加载的时候调用的方法
function initPage(){
	  // 取得隐藏变量pageId的值ֵ
  var pageId = document.getElementById("pageId").value;
  if(pageId==0){
	    // pageId==0代表注册
    document.getElementById("registerBtn").style.display="inline";
  } else {
	  // 代表修改
    document.getElementById("updateBtn").style.display="inline";
  }
}

